package com.wmuj.service.impl;

import com.wmuj.mapper.EmpMapper;
import com.wmuj.mapper.StudentMapper;
import com.wmuj.pojo.JobOption;
import com.wmuj.pojo.StudentOption;
import com.wmuj.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

  @Autowired private EmpMapper empMapper;
  @Autowired private StudentMapper studentMapper;

  /**
   * 员工职位人数统计
   *
   * @return
   */
  @Override
  public JobOption getEmpJobData() {
    List<Map<String, Object>> list = empMapper.countEmpJobData();
    System.out.println(list);
    List<Object> jobList = list.stream().map(map -> map.get("pos")).toList();
    List<Object> dataList = list.stream().map(map -> map.get("total")).toList();
    return new JobOption(jobList, dataList);
  }

  /**
   * 员工性别统计
   *
   * @return
   */
  @Override
  public List<Map> getEmpGenderData() {
    return empMapper.countEmpGenderData();
  }

  /**
   * 学员学历统计
   *
   * @return
   */
  @Override
  public List<Map> getStudentDegreeData() {
    return studentMapper.countStudentDegreeData();
  }

  /**
   * 班级人数统计
   *
   * @return
   */
  @Override
  public StudentOption getStudentCountData() {
    List<Map<String, Object>> list = studentMapper.countStudentCountData();
    System.out.println(list);
    List<Object> clazzList = list.stream().map(map -> map.get("name")).toList();
    List<Object> dataList = list.stream().map(map -> map.get("total")).toList();
    return new StudentOption(clazzList, dataList);
  }
}
